package mailsystem.gui;
import java.util.Scanner;

import mailsystem.Connection;
import mailsystem.Telephone;

public class ConsoleInterface implements Telephone {
	Scanner input = new Scanner(System.in);

	@Override
	public void run(Connection c) {
		boolean more = true;
		while (more) {
			String line = input.nextLine();
			if (line == null)
				return;
			if (line.equalsIgnoreCase("H"))
				c.hangup();
			else if (line.equalsIgnoreCase("Q"))
				more = false;
			else if (line.length() == 1 && "1234567890#".indexOf(line) >= 0)
				c.dial(line);
			else
				c.record(line);
		}
		System.exit(0);
	}

	@Override
	public void speak(String output) {
		System.out.println(output);
		
	}

	@Override
	public void showDisplay(String output) {
		System.out.println(output);
		
	}
}
